package com.prawn.ift.ctrlequipment.controller;


import com.prawn.ift.ctrlequipment.pojo.CtrlequipmentButton;
import com.prawn.ift.ctrlequipment.service.CtrlEquipmentButtonService;
import entity.Result;
import entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/12/13
 * @DESC： 控制设备通道按钮管理
 */
@Controller
public class CtrlEquipmentButtonController {

    @Autowired
    private CtrlEquipmentButtonService ctrlEquipmentButtonService;

    /**
     * 添加控制设备通道按钮信息
     * @Param ctrlEquipmentChannel
     * @return Result
     */
    @RequestMapping("/ctrlequipment/button/add")
    @ResponseBody
    public Result add(CtrlequipmentButton ctrlEquipmentChannel) {
        ctrlEquipmentChannel.setId(UUID.randomUUID().toString().replaceAll("-",""));
        ctrlEquipmentChannel.setCreateDate(new Date());
        ctrlEquipmentChannel.setUpdateDate(new Date());
        return ctrlEquipmentButtonService.addCtrlEquipmentButton(ctrlEquipmentChannel);
    }


    /**
     * 删除控制设备通道按钮信息
     * @Param id
     * @return Result
     */
    @RequestMapping("/ctrlequipment/button/delete")
    @ResponseBody
    public Result delete(String id) {
        return ctrlEquipmentButtonService.deleteCtrlEquipmentButton(id);
    }

    /**
     * 修改控制设备通道按钮信息
     * @Param ctrlEquipmentChannel
     * @return Result
     */
    @RequestMapping("/ctrlequipment/button/edit")
    @ResponseBody
    public Result edit(CtrlequipmentButton ctrlEquipmentButton) {
        ctrlEquipmentButton.setUpdateDate(new Date());
        return ctrlEquipmentButtonService.editCtrlEquipmentButton(ctrlEquipmentButton);
    }

    /**
     * 查询控制设备通道按钮信息
     * @return IftCtrlEquipmentChannel
     */
    @RequestMapping("/ctrlequipment/button/{id}")
    @ResponseBody
    public CtrlequipmentButton get(@PathVariable String id) {
        return ctrlEquipmentButtonService.getCtrlEquipmentButtonById(id);
    }

    /**
     * 查询控制设备id查询按钮信息列表
     * @return Result
     */
    @RequestMapping("/ctrlequipment/button/list")
    @ResponseBody
    public Result getList(String ctrlEquipmentId) {
        return ctrlEquipmentButtonService.getCtrlEquipmentButtonList(ctrlEquipmentId);
    }

    //通过设备控制通道id查询按钮的列表
    @RequestMapping("/ctrlequipment/button/queryByRelId")
    @ResponseBody
    public Result getListByRelId(String relId) {
        return ctrlEquipmentButtonService.getCtrlEquipmentButtonListByRelId(relId);
    }


    /**
     * 多条件控制设备通道信息列表
     * @return Result
     */
    @RequestMapping("/ctrlequipment/button/query")
    @ResponseBody
    public Result getPage(CtrlequipmentButton ctrlEquipmentButton) {
        return ctrlEquipmentButtonService.getCtrlEquipmentButtonListByVo(ctrlEquipmentButton);
    }

}
